<?php

namespace App\Admin\Forms;

use App\Exceptions\Arr;
use App\Jobs\AppointNumJob;
use App\Models\Appoint;
use App\Models\AppointNum;
use App\Models\HospitalAppoint;
use App\Models\HospitalAppointHoliday;
use App\Models\HospitalAppointInterval;
use App\Models\HospitalAppointIntervalNum;
use App\Models\HospitalAppointStreet;
use App\Models\HospitalAppointVaccine;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Alert;
use Dcat\Admin\Show;


class SetupSchedulingShow extends Show implements LazyRenderable
{
    use LazyWidget;

    public function render()
    {
        try {

            $payload = $this->payload;
            $hospitalAppointId= isset($payload['hospitalAppointId'])?$payload['hospitalAppointId']:0;
            $dates = AppointNum::SetupScheduling($hospitalAppointId,false,true);
            if($hospitalAppointId) {
                AppointNumJob::dispatch($hospitalAppointId);
            }

        }catch (\Exception $e) {
            return Alert::make($e->getMessage())->danger();
        }
        return Alert::make('初始化执行中，请稍后在排班管理中查看', '执行中')->warning();
    }
}
